<template>
  <div class="game-over-container">
    <div class="game-over-content">
      <h1>游戏结束</h1>
      <p class="score">最终得分：<span>{{ gameStore.games.score }}</span></p>
      
      <div class="buttons">
        <button class="retry" @click="handleRetry">再试一次</button>
        <button class="main-menu" @click="handleMainMenu">返回主菜单</button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { defineEmits } from 'vue'
import { useGameStore } from '@/store/game'
const gameStore = useGameStore();


// 定义事件
const emit = defineEmits(['retry', 'main-menu'])

// 按钮点击处理
const handleRetry = () => {
  emit('retry')
}

const handleMainMenu = () => {
  emit('main-menu')
}
</script>

<style scoped>
.game-over-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, #ff6b6b, #ffffff, #ff6b6b);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
  backdrop-filter: blur(2px);
}

.game-over-content {
  background: rgba(255, 255, 255, 0.9);
  padding: 2rem;
  border-radius: 15px;
  text-align: center;
  box-shadow: 0 0 20px rgba(0,0,0,0.3);
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

h1 {
  margin-bottom: 1rem;
  color: #333;
  font-size: 2rem;
}

.score {
  font-size: 1.2rem;
  color: #555;
  margin: 1.5rem 0;
}

.score span {
  color: #ff4444;
  font-weight: bold;
  font-size: 1.5rem;
}

.buttons button {
  margin: 0.5rem;
  padding: 0.8rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.retry {
  background: #4CAF50;
  color: white;
}

.retry:hover {
  background: #45a049;
  transform: translateY(-2px);
}

.main-menu {
  background: #2196F3;
  color: white;
}

.main-menu:hover {
  background: #1976D2;
  transform: translateY(-2px);
}
</style>